package luren.king.wechatlite.adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import luren.king.wechatlite.ui.ContactsFragment;
import luren.king.wechatlite.ui.FindFragment;
import luren.king.wechatlite.ui.MessageFragment;
import luren.king.wechatlite.ui.MineFragment;

public class ViewPagerAdapter extends FragmentStateAdapter {
    MessageFragment messageFragment = new MessageFragment();
    ContactsFragment contactsFragment  = new ContactsFragment();
    FindFragment findFragment = new FindFragment();
    MineFragment mineFragment = new MineFragment();

    public ViewPagerAdapter(@NonNull FragmentActivity fragmentActivity) {
        super(fragmentActivity);
    }

    public int getItemCount() {
        return 4;
    }

    @NonNull
    public Fragment createFragment(int position) {
        switch (position) {
            case 0:
                return messageFragment;
            case 1:
                return contactsFragment;
            case 2:
                return findFragment;
            case 3:
                return mineFragment;
            default:
                return null;
        }
    }
}
